package com.fhz.day013jetpackall.fragment;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;

import com.fhz.day013jetpackall.BannerRepository;
import com.fhz.day013jetpackall.entity.Banner;
import com.fhz.utilsfhz.ApiResponse;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class BannerViewModel extends ViewModel {

    private BannerRepository bannerRepository;

    @Inject
    public BannerViewModel(BannerRepository bannerRepository) {
        this.bannerRepository = bannerRepository;
    }

    public LiveData<ApiResponse<List<Banner>>> getBanner(){
        return bannerRepository.getBanner();
    }

    //本地
    public void insertBanners(Banner... banners){
        bannerRepository.insertBanner(banners);
    }

    //查询
    public List<Banner> query(){
       return  bannerRepository.getBanners();
    }
}